package com.motorola.dp.jenkinsmonitor.model.util.dom;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.motorola.dp.jenkinsmonitor.service.util.dom.DomChildProcessor;

/**
 *
 * Used for mapping instance field to child of a DOM node. E.g.:
 *
 *     <parent>
 *          <child/>
 *     </parent>
 *
 * can be mapped as:
 *
 *     @DomEntity(name="parent")
 *     class Parent {
 *         @DomChild
 *         Child;
 *     }
 *
 *Also, XPATH can be set to retrieve the needed child. E.g.:
 *
 *      <parent>
 *          <child>text</child>
 *      </parent>
 *
 * can be mapped as:
 *
 *     @DomEntity(name="parent")
 *     class Parent {
 *         @DomChild(xpath="//child/text()")
 *         String childText;
 *     }
 *
 * be aware, that node names in XPATH are CASE-SENSITIVE!!
 *
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@DomAnnotation(processor = DomChildProcessor.class)
public @interface DomChild {
    int childNumber() default 0;

    String XPATH_UNSPECIFIED = "[unspecified]";

    String xpath() default XPATH_UNSPECIFIED;
}
